<template>
  <div class="recommendBox">
    <div class="recommend-list">
      <div class="recommend-item" v-for="(item,index) in recommendList" :key='index' @click="$router.push('/product/'+item.id)">
        <img :src="item.imageHost + item.mainImage">
        <p>{{item.subtitle}}</p> <i>￥ {{item.price}}</i>
      </div>
    </div>
  </div>

</template>

<script>
import {getRecommend} from "../api/index";

export default {
  data() {
    return {
      recommendList: []
    }
  },
  methods: {
    fecthRecommend() {
      getRecommend().then(res => {
        this.recommendList = res
      })
    }
  },
  mounted() {
    this.fecthRecommend();
  }
}
</script>

<style lang="scss" scoped>
@import "../common/style/mixin.scss";

.recommend-list {
  display: flex;
  flex-shrink: 0;
  flex-wrap: wrap;
  width: 100%;
  margin-top: 30px;
  padding-bottom: 150px;
  @include boxSizing;
  background: #fff;

  .recommend-item {
    display: flex;
    flex-direction: column;
    width: 50%;
    padding: 20px;
    @include boxSizing;
    border-bottom: 1px solid #dcdcdc;

    &:nth-child(2n-1) {
      border-right: 1px solid #dcdcdc;
    }

    img {
      width: 100%;
      height: 290px;
      margin: 0 auto;
    }

    p {
      height: 60px;
      padding: 20px 0;
      font-size: 26px;
      line-height: 40px;
      color: #333;
      overflow: hidden;
    }

    i {
      font-style: normal;
      font-size: 32px;
      color: $red;
    }
  }
}
</style>
